<?php
require 'mail/PHPMailerAutoload.php';
/*sendmail函数调用说明
$setto  收件人邮箱
$subject  邮件标题
$nr   邮件内容
$usertitle 发件人名字
*/
function sendmail($setto, $subject, $nr, $usertitle = "")
{
    $mail = new PHPMailer;
//$mail->SMTPDebug = 3;                               // Enable verbose debug output
    $mail->isSMTP();                                     // Set mailer to use SMTP
    $mail->Host = '';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '';                 // SMTP username
    $mail->Password = '';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to
    $mail->CharSet = "utf-8";
    $mail->setFrom('', $usertitle);
    $mail->addAddress($setto);               // Name is optional
    $mail->Subject = $subject;
    $mail->Body = $nr;
    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}

?>